/*
 * Singleton.h
 *
 *  Created on: 5 sept. 2010
 *      Author: seeme
 *      Un classe singleton.
 *      ATTENTION: on ne singletone pas à la légère: les singleton == le MAAALL!
 */
//Not safe in multithread! Be carreful..

#ifndef SINGLETON_H_
#define SINGLETON_H_


template <class T> class Singleton{
public:
	static T* get();
	static void kill();

protected:
	static T* m_i;

private:
	T& operator=(const T&){}
};

template <class T> T* Singleton<T>::m_i=0;


template <class T>  T* Singleton<T>::get(){
        if(m_i==0){
                m_i=new T();
        }
        return m_i;
}

template <class T> void Singleton<T>::kill(){
        delete m_i;
        m_i=0;
}


#endif /* SINGLETON_H_ */
